$(document).ready(function() {         
			$("#schoolCardinfo").jqGrid(
			{
				url : global_url+global_urijs+'schoolica_search_normal'+global_suffix+"?sid="+global_sid+"&tid="+global_tid,
				datatype : "json",
				mtype : 'GET',
				height:300, 
				width:770,
				colNames : [ 'IC卡号','卡状态','操作','状态','icid' ],
				colModel : [ {name : 'cardnum',index : 'cardnum',width : 100,align:'center'}, 
							 {name : 'state_str',index : 'state_str',width : 100,sortable : false,align:'center'}, 
							 {name : 'option',index : 'option',width : 100,sortable : false,align:'center'}, 
							 {name:'state',index:'state',hidden:true},
							 {name:'icid',index:'icid',hidden:true}
						   ],
				//autowidth:true,
				jsonReader : {
					root : "schoolIcCardList",
					page : "page",
					total : "page_count",
					repeatitems : false
				},
				pager : jQuery("#schoolCardpage"),
				prmNames : {
					page : "page",
					sort : "sort"
				},
				rowNum : 10,
				//rowList: [10, 20, 30],
				sortname : 'cardnum',
				hidegrid : false,
				sortorder : 'asc',
				viewrecords : true,
				caption : 'IC卡信息',
				gridComplete:function(){
					var ids=jQuery("#schoolCardinfo").jqGrid('getDataIDs');
					for(var i=0; i<ids.length; i++){
						var id=ids[i];   
						var state_str = jQuery("#schoolCardinfo").jqGrid('getRowData', id).state_str;
						jh = "<a href='javascript:;'  class='jqtrow' onclick='upTel_qd(" + id + ")'>启用</a>"; 
						zx = "<a href='javascript:;'  class='jqtrow' onclick='upTel_zx(" + id + ")'>注销</a>"; 						
						var re = jh;
						if(state_str=="启用"){
							re = zx;
						}
						jQuery("#schoolCardinfo").jqGrid('setRowData', ids[i],{ option:re});
					}
				}
			}).navGrid("#schoolCardpage", {edit : false,add : false,del : false,search : false});
		});

function upTel_qd(id){
	var icid = jQuery("#schoolCardinfo").jqGrid('getRowData', id).icid;
	var fun = function(data) {
		$("#schoolCardinfo").trigger("reloadGrid");
	};
	exeAjax(ajaxUrl(global_url+global_urijs+'schoolica_updateSchoolIcardState'+global_suffix), fun, 
		{"sid" : global_sid,"icid" :icid,"state":10});
}

function upTel_zx(id){
	var icid = jQuery("#schoolCardinfo").jqGrid('getRowData', id).icid;
	var fun = function(data) {
		$("#schoolCardinfo").trigger("reloadGrid");
	};
	exeAjax(ajaxUrl(global_url+global_urijs+'schoolica_updateSchoolIcardState'+global_suffix), fun, 
		{"sid" : global_sid,"icid" :icid,"state":20});
}
